package org.bbelovic.devel.metro.wsdlfirst.client;

import java.io.IOException;

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;

public class MyCallbackHandler implements CallbackHandler {

    @Override
    public void handle(Callback[] callbacks) throws IOException,
            UnsupportedCallbackException {
        for (Callback callback: callbacks) {
            if (callback instanceof NameCallback) {
                ((NameCallback) callback).setName("bbelovic");
            } else if (callback instanceof PasswordCallback) {
                ((PasswordCallback) callback).setPassword("mypasswd".toCharArray());
            }
            else {
                System.out.println("Unknown callback");
            }
        }

    }

}
